<?php

class Coursemodel extends CI_Model {

	function __construct()
    {
        parent::__construct();
	    $this->load->database();
    }


    function getCourselist($param){

  	 	$pageno = $param['pageno'];
  	 	$stype = $param['stype'];
  	 	$areaid = $param['areaid'];
  	 	$sorttype = $param['sorttype'];

  	 	$pagesize = (int)$param['pagesize'];

  	 	$rs_number = ($pageno - 1) * $pagesize ;

  	 	$wherestr = ' where status=1 ';
  	 	if( $stype !='0' && $stype!=''&& $stype!='all'){
  	 		$wherestr = $wherestr.' and stype_main='.$stype ; 
  	 	}
  	 	if( $areaid !='0' && $areaid!=''&& $areaid!='all'){
  	 		$wherestr = $wherestr.' and areaid='.$areaid ; 
  	 	}

	    $query = $this->db->query('SELECT * FROM course '.$wherestr.' limit ?,?' , array($rs_number, $pagesize));
  		
  		$res =  $query->result();
        return $res;

    }


    function getCourse($param){
        $cid = $param['cid'];
        $query = $this->db->query("select * FROM course where id=?",array($cid));
    	$res =  $query->row();
 
      	return $res;
    }


}

?>